package com.xscr.forum.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.xscr.forum.mapper.ForumCircleMapper;
import com.xscr.forum.po.ForumCircle;
import com.xscr.forum.service.ForumCircleService;
import com.xscr.mybatis.utility.PageBean;


public class ForumCircleServiceImpl implements ForumCircleService {

	@Autowired
	private ForumCircleMapper forumCircleMapper;
	
	@Override
	public int saveForumCircle(ForumCircle forumCircle) throws Exception {
		return forumCircleMapper.insertSelective(forumCircle);
	}

	@Override
	public int saveListForumCircles(List<ForumCircle> forumCircles)
			throws Exception {
		return forumCircleMapper.insertListForumCircles(forumCircles);
	}

	@Override
	public int deleteForumCircleById(Integer id) throws Exception {
		ForumCircle forumCircle = new ForumCircle();
		forumCircle.setCircleId(id);;
		forumCircle.setStatus(-1);
		
		return forumCircleMapper.updateByPrimaryKeySelective(forumCircle);
	}

	@Override
	public int updateForumCircle(ForumCircle forumCircle) throws Exception {
		
		return forumCircleMapper.updateByPrimaryKeySelective(forumCircle);
	}

	@Override
	public ForumCircle findForumCircleById(Integer id) throws Exception {
		
		return forumCircleMapper.selectByPrimaryKey(id);
	}
	
	@Override
	public PageBean<ForumCircle> findForumCircleByConditions(PageBean<ForumCircle> pageBean) throws Exception {
		
		List<ForumCircle> selectForumCircleListPage = forumCircleMapper.selectForumCircleListPage(pageBean);
		
		pageBean.setResult(selectForumCircleListPage);
		
		return pageBean;
	}
	

	@Override
	public List<ForumCircle> findForumCircleByConditions(ForumCircle forumCircle)
			throws Exception {
		PageBean<ForumCircle> pageBean = new PageBean<ForumCircle>();
		
		pageBean.setParameter(forumCircle);
		
		
		return forumCircleMapper.selectForumCircleListPage(pageBean);
	}

}
